/**
 * 前端类型定义
 *
 * 这个文件定义了前端应用中使用的所有数据类型
 * 与后端API的响应格式保持一致
 */

// 用户相关类型
export interface User {
  id: number;
  username: string;
  role: string;
  is_active: boolean;
  created_at: string;
  updated_at?: string;
}

export interface LoginRequest {
  username: string;
  password: string;
}

export interface LoginResponse {
  access_token: string;
  token_type: string;
  expires_in: number;
}

// 轮播图相关类型
export interface Banner {
  id: number;
  title: string;
  subtitle?: string;
  image_url: string;
  link_url?: string;
  description?: string;
  is_active: boolean;
  sort_order: number;
  created_at: string;
  updated_at?: string;
}

export interface BannerCreate {
  title: string;
  subtitle?: string;
  image_url: string;
  link_url?: string;
  description?: string;
  is_active?: boolean;
  sort_order?: number;
}

export interface BannerUpdate {
  title?: string;
  subtitle?: string;
  image_url?: string;
  link_url?: string;
  description?: string;
  is_active?: boolean;
  sort_order?: number;
}

// 新闻相关类型
export interface News {
  id: number;
  title: string;
  excerpt?: string;
  content: string;
  cover_image?: string;
  category: string;
  author: string;
  is_published: boolean;
  is_featured: boolean;
  view_count: number;
  published_at: string;
  created_at: string;
  updated_at?: string;
}

export interface NewsCreate {
  title: string;
  excerpt?: string;
  content: string;
  cover_image?: string;
  category?: string;
  author?: string;
  is_published?: boolean;
  is_featured?: boolean;
}

export interface NewsUpdate {
  title?: string;
  excerpt?: string;
  content?: string;
  cover_image?: string;
  category?: string;
  author?: string;
  is_published?: boolean;
  is_featured?: boolean;
}

// 公告公示类型（与新闻结构相同）
export interface Announcement {
  id: number;
  title: string;
  excerpt?: string;
  content: string;
  cover_image?: string;
  category: string;
  author: string;
  is_published: boolean;
  is_featured: boolean;
  view_count: number;
  published_at: string;
  created_at: string;
  updated_at?: string;
}

export interface AnnouncementCreate {
  title: string;
  excerpt?: string;
  content: string;
  cover_image?: string;
  category?: string;
  author?: string;
  is_published?: boolean;
  is_featured?: boolean;
}

export interface AnnouncementUpdate {
  title?: string;
  excerpt?: string;
  content?: string;
  cover_image?: string;
  category?: string;
  author?: string;
  is_published?: boolean;
  is_featured?: boolean;
}



// 服务相关类型
export interface Service {
  id: number;
  name: string;
  description?: string;
  content?: string;
  icon_url?: string;
  category?: string;
  price?: number;
  features?: string; // JSON字符串
  is_active: boolean;
  is_featured: boolean;
  sort_order: number;
  created_at: string;
  updated_at?: string;
}

export interface ServiceCreate {
  name: string;
  description?: string;
  content?: string;
  icon_url?: string;
  category?: string;
  price?: number;
  features?: string;
  is_active?: boolean;
  is_featured?: boolean;
  sort_order?: number;
}

export interface ServiceUpdate {
  name?: string;
  description?: string;
  content?: string;
  icon_url?: string;
  category?: string;
  price?: number;
  features?: string;
  is_active?: boolean;
  is_featured?: boolean;
  sort_order?: number;
}

export interface ServiceCategory {
  category: string;
  count: number;
}

// 公司信息相关类型
export interface CompanyInfo {
  id?: number;
  company_name: string;
  company_logo?: string;
  about_us_image?: string;
  company_slogan?: string;
  company_description?: string;

  // 统计卡片字段
  stat1_title?: string;
  stat1_value?: string;
  stat2_title?: string;
  stat2_value?: string;
  stat3_title?: string;
  stat3_value?: string;
  stat4_title?: string;
  stat4_value?: string;

  company_introduction?: string;
  company_vision?: string;
  company_mission?: string;
  company_values?: string;
  created_at?: string;
  updated_at?: string;
}

export interface ContactInfo {
  phone?: string;
  email?: string;
  fax?: string;
  address?: string;
  website?: string;
}

// 文件上传相关类型
export interface UploadResponse {
  filename: string;
  original_filename: string;
  file_path: string;
  file_url: string;
  file_size: number;
  content_type: string;
}

export interface ImageUploadResponse extends UploadResponse {
  width?: number;
  height?: number;
  thumbnail_url?: string;
}

// 分页相关类型
export interface PaginationParams {
  page?: number;
  size?: number;
}

export interface PaginatedResponse<T> {
  items: T[];
  total: number;
  page: number;
  size: number;
  pages: number;
}

// 留言相关类型
export interface Message {
  id: number;
  name: string;
  phone: string;
  email?: string;
  subject?: string;
  message: string;
  is_read: boolean;
  is_replied: boolean;
  reply_content?: string;
  reply_time?: string;
  created_at: string;
  updated_at?: string;
}

export interface MessageCreate {
  name: string;
  phone: string;
  email?: string;
  subject?: string;
  message: string;
}

export interface MessageUpdate {
  is_read?: boolean;
  is_replied?: boolean;
  reply_content?: string;
}

export interface MessageStats {
  total: number;
  unread: number;
  unreplied: number;
  today: number;
}